package main

import (
	"bytes"
	"fmt"
	"net/http"
	"os"
	"reflect"
)

func checkErr(err error) {
	if err != nil {
		fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
		os.Exit(1)
	}
}
func main() {
	resp, err := http.Get("https://baidu.com")
	//checkErr(err)
	defer resp.Body.Close()

	if err == nil {
		fmt.Println("statusCode: ", resp.StatusCode)
		fmt.Println(resp.Status)
		fmt.Println(reflect.TypeOf(resp.Body))

		buf := bytes.NewBuffer(make([]byte, 0, 512))
		length, _ := buf.ReadFrom(resp.Body)
		fmt.Println(length)
		fmt.Println(string(buf.Bytes()))
	}

}
